<template>
  <div>
    <el-select v-model="value" :multiple="false" collapse-tags style="width: 100%" @change="handleChange"
      :placeholder="$t('labels.pleaseSelect')">
      <el-option v-for="item in datas" :key="item.id" :label="item.name" :value="item.id">
      </el-option>
    </el-select>
  </div>
</template>
<script>
import { getBankAccounts } from "@/api/bank";
export default {
  data() {
    return {
      datas: [],
      value: "",
    };
  },
  model: {
    prop: "id",
    event: "innerChange",
  },
  methods: {
    getData() {
      getBankAccounts().then((res) => {
        this.datas = res ? res : [];
      });
    },
    handleChange() {
      this.$emit("innerChange", this.value);
      this.$emit("change", this.value)
    },
  },
  watch: {
    id: {
      handler(value) {
        this.value = value;
      },
    },
  },
  mounted() {
    this.value = this.id;
    this.getData();
  },
  props: {
    id: {
      type: String,
    },
  },
};
</script>
